﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace DSSDataServiceGenerator.Commands
{
    public class ModelCommand
        : ICommand
    {
        private Action<object> _Execute;
        private Func<object, Boolean> _CanExecute;

        public ModelCommand(Func<object, Boolean> canExecute, Action<object> execute)
        {
            this._CanExecute = canExecute;

            this._Execute = execute;
        }

        public event EventHandler CanExecuteChanged
        {
            add
            {
                CommandManager.RequerySuggested += value;
            }
            remove
            {
                CommandManager.RequerySuggested -= value;
            }
        }

        public Boolean CanExecute(Object parameter)
        {
            return _CanExecute(parameter);
        }

        public void Execute(Object parameter)
        {
            _Execute(parameter);
        }
    }
}
